import React from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'

const Summary = ({value}) => {
  return (
    <div>
      Total: {value}
    </div>
  )
}
Summary.propTypes = {
  value: PropTypes.number.isRequired
}

function mapStateToProps(state,ownProps){
  let sum = 0
  for(let [,value] of Object.entries(state)){
    sum += value
  }
  return {
    value: sum
  }
}

export default connect(mapStateToProps)(Summary)
